var webpack = require('webpack');
var path = require('path');

var config = {
	entry: [
		'webpack/hot/dev-server',
		'webpack-dev-server/client?http://localhost:8080',
		'./src/main.jsx'
	],
	resolve: {
		root: [
			// allows us to import modules as if /src was the root.
			// so I can do: import Comment from 'components/Comment'
			// instead of:  import Comment from '../components/Comment' or whatever relative path would be
			path.resolve(__dirname, './src')
		],
		// allows you to require without the .js at end of filenames
		// import Component from 'component' vs. import Component from 'component.js'
		extensions: ['', '.js', '.json', '.jsx']
	},
	output: {
		path: path.resolve(__dirname, 'dist'),
		publicPath: "/",
		filename: 'bundle.js'
	},
	devServer: {
		contentBase: './dist',
		hot: true
	},
	plugins: [
    	new webpack.HotModuleReplacementPlugin()
  	],
	module: {
		loaders: [{
			test: /\.jsx?$/,
			// dont run node_modules or bower_components through babel loader
			exclude: /node_modules/,
			// babel is alias for babel-loader
			// npm i babel-core babel-loader --save-dev
			loader: 'react-hot!babel'
		}, {
            test: /\.css$/,
            loader: 'style!css!autoprefixer?browsers=last 2 versions'
        }, {
            test: /\.png$/,
            loader: 'url?limit=8192&mimetype=image/png',
        }, {
            test: /\.less$/,
            loader: "style!css!less"
        }],
	}
}

module.exports = config;
